
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/assumptions/assume.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:26:00 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Assume &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../live.sympy.org/static/live-sphinx.js"></script>
    
    <link rel="shortcut icon" href="../../_static/sympy-notailtext-favicon.ico"/>
    <link href="assume.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Refine" href="refine.html" />
    <link rel="prev" title="Ask" href="ask.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="refine.html" title="Refine"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="ask.html" title="Ask"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" accesskey="U">Assumptions</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Assume</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-sympy.assumptions.assume">
<span id="assume"></span><h1>Assume<a class="headerlink" href="#module-sympy.assumptions.assume" title="Permalink to this headline">¶</a></h1>
<p>A module which implements predicates and assumption context.</p>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.assumptions.assume.AppliedPredicate">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.assumptions.assume.</span></span><span class="sig-name descname"><span class="pre">AppliedPredicate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">predicate</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/assumptions/assume.py#L81-L172"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.assumptions.assume.AppliedPredicate" title="Permalink to this definition">¶</a></dt>
<dd><p>The class of expressions resulting from applying <code class="docutils literal notranslate"><span class="pre">Predicate</span></code> to
the arguments. <code class="docutils literal notranslate"><span class="pre">AppliedPredicate</span></code> merely wraps its argument and
remain unevaluated. To evaluate it, use the <code class="docutils literal notranslate"><span class="pre">ask()</span></code> function.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Q</span><span class="p">,</span> <span class="n">ask</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Q</span><span class="o">.</span><span class="n">integer</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="go">Q.integer(1)</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">function</span></code> attribute returns the predicate, and the <code class="docutils literal notranslate"><span class="pre">arguments</span></code>
attribute returns the tuple of arguments.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">type</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">integer</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
<span class="go">&lt;class &#39;sympy.assumptions.assume.AppliedPredicate&#39;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Q</span><span class="o">.</span><span class="n">integer</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">function</span>
<span class="go">Q.integer</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Q</span><span class="o">.</span><span class="n">integer</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">arguments</span>
<span class="go">(1,)</span>
</pre></div>
</div>
<p>Applied predicates can be evaluated to a boolean value with <code class="docutils literal notranslate"><span class="pre">ask</span></code>:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ask</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">integer</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
<span class="go">True</span>
</pre></div>
</div>
<dl class="py property">
<dt class="sig sig-object py" id="sympy.assumptions.assume.AppliedPredicate.arg">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">arg</span></span><a class="headerlink" href="#sympy.assumptions.assume.AppliedPredicate.arg" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the expression used by this assumption.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Q</span><span class="p">,</span> <span class="n">Symbol</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">Q</span><span class="o">.</span><span class="n">integer</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">arg</span>
<span class="go">x + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.assumptions.assume.AppliedPredicate.arguments">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">arguments</span></span><a class="headerlink" href="#sympy.assumptions.assume.AppliedPredicate.arguments" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the arguments which are applied to the predicate.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.assumptions.assume.AppliedPredicate.function">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">function</span></span><a class="headerlink" href="#sympy.assumptions.assume.AppliedPredicate.function" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the predicate.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.assumptions.assume.AssumptionsContext">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.assumptions.assume.</span></span><span class="sig-name descname"><span class="pre">AssumptionsContext</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/assumptions/assume.py#L15-L76"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.assumptions.assume.AssumptionsContext" title="Permalink to this definition">¶</a></dt>
<dd><p>Set containing default assumptions which are applied to the <code class="docutils literal notranslate"><span class="pre">ask()</span></code>
function.</p>
<p class="rubric">Explanation</p>
<p>This is used to represent global assumptions, but you can also use this
class to create your own local assumptions contexts. It is basically a thin
wrapper to Python’s set, so see its documentation for advanced usage.</p>
<p class="rubric">Examples</p>
<p>The default assumption context is <code class="docutils literal notranslate"><span class="pre">global_assumptions</span></code>, which is initially empty:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ask</span><span class="p">,</span> <span class="n">Q</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.assumptions</span> <span class="kn">import</span> <span class="n">global_assumptions</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">global_assumptions</span>
<span class="go">AssumptionsContext()</span>
</pre></div>
</div>
<p>You can add default assumptions:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">global_assumptions</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">real</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">global_assumptions</span>
<span class="go">AssumptionsContext({Q.real(x)})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ask</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">real</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
<span class="go">True</span>
</pre></div>
</div>
<p>And remove them:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">global_assumptions</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">real</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">ask</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">real</span><span class="p">(</span><span class="n">x</span><span class="p">)))</span>
<span class="go">None</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">clear()</span></code> method removes every assumption:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">global_assumptions</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">positive</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">global_assumptions</span>
<span class="go">AssumptionsContext({Q.positive(x)})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">global_assumptions</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">global_assumptions</span>
<span class="go">AssumptionsContext()</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.assumptions.assume.assuming" title="sympy.assumptions.assume.assuming"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assuming</span></code></a></p>
</div>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.assumptions.assume.AssumptionsContext.add">
<span class="sig-name descname"><span class="pre">add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">assumptions</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/assumptions/assume.py#L68-L71"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.assumptions.assume.AssumptionsContext.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add assumptions.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.assumptions.assume.Predicate">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.assumptions.assume.</span></span><span class="sig-name descname"><span class="pre">Predicate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/assumptions/assume.py#L225-L356"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.assumptions.assume.Predicate" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class for mathematical predicates. It also serves as a
constructor for undefined predicate objects.</p>
<p class="rubric">Explanation</p>
<p>Predicate is a function that returns a boolean value [1].</p>
<p>Predicate function is object, and it is instance of predicate class.
When a predicate is applied to arguments, <code class="docutils literal notranslate"><span class="pre">AppliedPredicate</span></code>
instance is returned. This merely wraps the argument and remain
unevaluated. To obtain the truth value of applied predicate, use the
function <code class="docutils literal notranslate"><span class="pre">ask</span></code>.</p>
<p>Evaluation of predicate is done by multiple dispatching. You can
register new handler to the predicate to support new types.</p>
<p>Every predicate in SymPy can be accessed via the property of <code class="docutils literal notranslate"><span class="pre">Q</span></code>.
For example, <code class="docutils literal notranslate"><span class="pre">Q.even</span></code> returns the predicate which checks if the
argument is even number.</p>
<p>To define a predicate which can be evaluated, you must subclass this
class, make an instance of it, and register it to <code class="docutils literal notranslate"><span class="pre">Q</span></code>. After then,
dispatch the handler by argument types.</p>
<p>If you directly construct predicate using this class, you will get
<code class="docutils literal notranslate"><span class="pre">UndefinedPredicate</span></code> which cannot be dispatched. This is useful
when you are building boolean expressions which do not need to be
evaluated.</p>
<p class="rubric">Examples</p>
<p>Applying and evaluating to boolean value:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Q</span><span class="p">,</span> <span class="n">ask</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ask</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">prime</span><span class="p">(</span><span class="mi">7</span><span class="p">))</span>
<span class="go">True</span>
</pre></div>
</div>
<p>You can define a new predicate by subclassing and dispatching. Here,
we define a predicate for sexy primes [2] as an example.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Predicate</span><span class="p">,</span> <span class="n">Integer</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">SexyPrimePredicate</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">name</span> <span class="o">=</span> <span class="s2">&quot;sexyprime&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Q</span><span class="o">.</span><span class="n">sexyprime</span> <span class="o">=</span> <span class="n">SexyPrimePredicate</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nd">@Q</span><span class="o">.</span><span class="n">sexyprime</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">Integer</span><span class="p">,</span> <span class="n">Integer</span><span class="p">)</span>
<span class="gp">... </span><span class="k">def</span> <span class="nf">_</span><span class="p">(</span><span class="n">int1</span><span class="p">,</span> <span class="n">int2</span><span class="p">,</span> <span class="n">assumptions</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">args</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">([</span><span class="n">int1</span><span class="p">,</span> <span class="n">int2</span><span class="p">])</span>
<span class="gp">... </span>    <span class="k">if</span> <span class="ow">not</span> <span class="nb">all</span><span class="p">(</span><span class="n">ask</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">prime</span><span class="p">(</span><span class="n">a</span><span class="p">),</span> <span class="n">assumptions</span><span class="p">)</span> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">args</span><span class="p">):</span>
<span class="gp">... </span>        <span class="k">return</span> <span class="kc">False</span>
<span class="gp">... </span>    <span class="k">return</span> <span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mi">6</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ask</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">sexyprime</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">11</span><span class="p">))</span>
<span class="go">True</span>
</pre></div>
</div>
<p>Direct constructing returns <code class="docutils literal notranslate"><span class="pre">UndefinedPredicate</span></code>, which can be
applied but cannot be dispatched.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Predicate</span><span class="p">,</span> <span class="n">Integer</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Q</span><span class="o">.</span><span class="n">P</span> <span class="o">=</span> <span class="n">Predicate</span><span class="p">(</span><span class="s2">&quot;P&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">type</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">P</span><span class="p">)</span>
<span class="go">&lt;class &#39;sympy.assumptions.assume.UndefinedPredicate&#39;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Q</span><span class="o">.</span><span class="n">P</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="go">Q.P(1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Q</span><span class="o">.</span><span class="n">P</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">Integer</span><span class="p">)(</span><span class="k">lambda</span> <span class="n">expr</span><span class="p">,</span> <span class="n">assump</span><span class="p">:</span> <span class="kc">True</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
  <span class="c">...</span>
<span class="gr">TypeError</span>: <span class="n">&lt;class &#39;sympy.assumptions.assume.UndefinedPredicate&#39;&gt; cannot be dispatched.</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r1"><span class="brackets"><a class="fn-backref" href="#id1">R1</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Predicate_(mathematical_logic">https://en.wikipedia.org/wiki/Predicate_(mathematical_logic</a>)</p>
</dd>
<dt class="label" id="r2"><span class="brackets"><a class="fn-backref" href="#id2">R2</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Sexy_prime">https://en.wikipedia.org/wiki/Sexy_prime</a></p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.assumptions.assume.Predicate.eval">
<span class="sig-name descname"><span class="pre">eval</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">assumptions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/assumptions/assume.py#L341-L352"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.assumptions.assume.Predicate.eval" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate <code class="docutils literal notranslate"><span class="pre">self(*args)</span></code> under the given assumptions.</p>
<p>This uses only direct resolution methods, not logical inference.</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="sympy.assumptions.assume.Predicate.handler">
<span class="sig-name descname"><span class="pre">handler</span></span><em class="property"> <span class="pre">=</span> <span class="pre">&lt;dispatched</span> <span class="pre">AskPredicateHandler&gt;</span></em><a class="headerlink" href="#sympy.assumptions.assume.Predicate.handler" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.assumptions.assume.Predicate.register">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">register</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">types</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/assumptions/assume.py#L317-L324"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.assumptions.assume.Predicate.register" title="Permalink to this definition">¶</a></dt>
<dd><p>Register the signature to the handler.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.assumptions.assume.Predicate.register_many">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">register_many</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">types</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/assumptions/assume.py#L326-L336"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.assumptions.assume.Predicate.register_many" title="Permalink to this definition">¶</a></dt>
<dd><p>Register multiple signatures to same handler.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.assumptions.assume.UndefinedPredicate">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.assumptions.assume.</span></span><span class="sig-name descname"><span class="pre">UndefinedPredicate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">handlers</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/assumptions/assume.py#L359-L453"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.assumptions.assume.UndefinedPredicate" title="Permalink to this definition">¶</a></dt>
<dd><p>Predicate without handler.</p>
<p class="rubric">Explanation</p>
<p>This predicate is generated by using <code class="docutils literal notranslate"><span class="pre">Predicate</span></code> directly for
construction. It does not have a handler, and evaluating this with
arguments is done by SAT solver.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Predicate</span><span class="p">,</span> <span class="n">Q</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Q</span><span class="o">.</span><span class="n">P</span> <span class="o">=</span> <span class="n">Predicate</span><span class="p">(</span><span class="s1">&#39;P&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Q</span><span class="o">.</span><span class="n">P</span><span class="o">.</span><span class="n">func</span>
<span class="go">&lt;class &#39;sympy.assumptions.assume.UndefinedPredicate&#39;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Q</span><span class="o">.</span><span class="n">P</span><span class="o">.</span><span class="n">name</span>
<span class="go">Str(&#39;P&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.assumptions.assume.assuming">
<span class="sig-prename descclassname"><span class="pre">sympy.assumptions.assume.</span></span><span class="sig-name descname"><span class="pre">assuming</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">assumptions</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/assumptions/assume.py#L456-L478"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.assumptions.assume.assuming" title="Permalink to this definition">¶</a></dt>
<dd><p>Context manager for assumptions.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.assumptions</span> <span class="kn">import</span> <span class="n">assuming</span><span class="p">,</span> <span class="n">Q</span><span class="p">,</span> <span class="n">ask</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">ask</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">integer</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="p">)))</span>
<span class="go">None</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">with</span> <span class="n">assuming</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">integer</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">Q</span><span class="o">.</span><span class="n">integer</span><span class="p">(</span><span class="n">y</span><span class="p">)):</span>
<span class="gp">... </span>    <span class="nb">print</span><span class="p">(</span><span class="n">ask</span><span class="p">(</span><span class="n">Q</span><span class="o">.</span><span class="n">integer</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="p">)))</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h4>Previous topic</h4>
  <p class="topless"><a href="ask.html"
                        title="previous chapter">Ask</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="refine.html"
                        title="next chapter">Refine</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/modules/assumptions/assume.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="refine.html" title="Refine"
             >next</a> |</li>
        <li class="right" >
          <a href="ask.html" title="Ask"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" >Assumptions</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Assume</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/assumptions/assume.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:26:01 GMT -->
</html>